package java_thinking.unit_14._14_2;

/**
 * @Description :
 * @author: cww
 * @DateTime: 2019-03-27 23:07
 */
class Line extends FancyToy {

}
public class Generics {
    public static void main(String[] args) {
        Class<?> intClass = int.class;
        intClass = double.class;
        Class<Integer> integerClass = int.class;
//        integerClass = double.class;编译无法通过，因为上面声明了指向Integer类的引用

        Class<? extends Number> bounded = int.class;
        bounded = double.class;
        bounded = Number.class;
        //或者其他任何Number派生类

        try {
            Class<FancyToy> ftClass = FancyToy.class;
            //newInstance()返回对象的确切类型
            FancyToy fancyToy = ftClass.newInstance();
            Class<? super FancyToy> up = ftClass.getSuperclass();
            //无法编译通过 FancyToy extends Toy 因为.getSuperclass()返回的是基类(不是接口)，
            // 而编译器在编译时候就知道他是什么类型了  不明白！！！
            //Class<Toy> up2 = ftClass.getSuperclass()

            Object o = up.newInstance();
        } catch (Exception e) {
        }
    }
}
